package com.scy.java.object.customer;
//账户类
public class Account {
    private int id;//账号
    private double balance;//余额
    private double rate;//年利率
    Account(){
        //无参构造器
    }
    //全参构造器
    public Account(int id, double balance, double rate) {
        //调用无参构造器，必须要在首航出现
        this();
//        this.id是账户
        this.id = id;
        this.balance = balance;
        this.rate = rate;
    }
    //存钱
    public void deposit(double amount){
        if (amount>0){
            balance+=amount;
            System.out.println("成功存入："+amount);
        }
    }
    //取钱
    public void withDraw(double money){
        if (money<=balance && money>0){
            balance -= money ;
            System.out.println("成功取出："+money);
        }else {
            System.out.println("余额不足！");
        }
    }
    //get()有返回值、set()没有
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", balance=" + balance +
                ", rate=" + rate +
                '}';
    }
}
